import { createPinia } from "pinia";
import { createPersistedState } from "pinia-plugin-persistedstate";

const pinia = createPinia()

pinia.use(createPersistedState({
    storage: {
        getItem: (key) => uni.getStorageSync(key),
        setItem: (key, value) => uni.setStorageSync(key, value),
    },
    // 添加性能优化配置
    auto: true,
    beforeRestore: (context) => {
        console.log('Before hydration...')
    },
    afterRestore: (context) => {
        console.log('After hydration...')
    }
}))

export default pinia